package validator;

import entity.User;
import manager.UserManager;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class LoginValidator implements Validator {

    private UserManager userManager;

    @Override
    public boolean supports(Class clazz) {
        //just validate the Customer instances
        return User.class.isAssignableFrom(clazz);

    }

    @Override
    public void validate(Object target, Errors errors) {

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name",
                "required.userName", "Field name is required.");


        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pass",
                "required.password", "Field name is required.");
    }

    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }
}